/*** Trigger Name: ifulfillRestrictEditWActivities 
 * Author: Accenture
 * Date: 10-feb-2012
 * Requirement/Project Name: iFulfill
 * Requirement Description: 
 **/
 
trigger ifulfillRestrictEditWActivities on Workflow_Activities__c ( before Update)
{

    list<Wokflow_Steps__c> wfstepList = new list<Wokflow_Steps__c>();
    Set<ID> wfId = new Set<Id>(); 
    for(Workflow_Activities__c wfActObj: trigger.new) 
    {     
        wfId.add(wfActObj.Step_Name__c); 
    } 

    wfstepList =[select id from Wokflow_Steps__c where (Wokflow_Stage_Name__r.Workflow_Code__r.status__c ='Inactive' or Wokflow_Stage_Name__r.Workflow_Code__r.status__c = 'Pending Inactivation' )];
                
    wfId.clear(); 
    for(Wokflow_Steps__c wfActObj: wfstepList) 
    {     
         wfId.add(wfActObj.id); 
    }   
    for(Workflow_Activities__c wfActObj: trigger.new) 
    {     
        if(wfID.contains(wfActObj.Step_Name__c))      
        {            
            wfActObj.adderror('Workflow Activity cannot be edit if  workflow definition is in Inactive or Pending Inactivation');          
        }  
    }
}